package com.sk.ccflower.server.lib.sysUtils;

import com.sk.ccflower.server.lib.sysBeans.CpuLoadBean;
import com.sk.ccflower.server.lib.sysBeans.CpuStatBean;
import com.sk.ccflower.server.lib.sysBeans.ProcCpuLoadBean;
import com.sk.ccflower.server.lib.sysBeans.ProcStatBean;


/**
 * @author eunwoogi
 * @since 2009. 11. 11.
 */
public class SysResCollect implements SysResCollectFacade {
	
	SysResCollectFacade m_collect;
	
	public SysResCollect() {
		String os = System.getProperties().getProperty( "os.name" );
		
		if ( os.toLowerCase().indexOf("linux") >= 0 ) {
			m_collect = new SysResCollectImpl_Linux();
		} else if ( os.toLowerCase().indexOf("window") >= 0 ) {
			m_collect = new SysResCollectImpl_Windows();
		} else {
			m_collect = new SysResCollectImpl_Unknown();
		}
	}
	
	public int getPid( String name ) throws Exception {
		return this.m_collect.getPid(name);
	}
	
	public String getCpuStat() throws Exception {
		return this.m_collect.getCpuStat();
	}
	
	public CpuStatBean parseCpuStat( String stat ) throws Exception {
		return this.m_collect.parseCpuStat(stat);
	}
	
	public CpuLoadBean getCpuLoad( CpuStatBean oldData, CpuStatBean newData ) throws Exception {
		return this.m_collect.getCpuLoad(oldData, newData);
	}
	
	public String getProcStat( int pid ) throws Exception {
		return this.m_collect.getProcStat(pid);
	}
	
	public ProcStatBean parseProcStat( String stat ) throws Exception {
		return this.m_collect.parseProcStat(stat);
	}
	
	public ProcCpuLoadBean getProcCpuLoad( ProcStatBean oldProc, ProcStatBean newProc, CpuStatBean oldCpu, CpuStatBean newCpu ) throws Exception {
		return this.m_collect.getProcCpuLoad(oldProc, newProc, oldCpu, newCpu);
	}
	
}
